home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / cdity / ModeProSrc.lha / Prefs / MPPReqs.c < prev    next >
C/C++ Source or Header  |  1998-07-29  |  7KB  |  210 lines

  1. #include "MPP.h"
  2.  
  3. extern struct MPSem *MPSem;
  4. extern STRPTR MiscText[];
  5. extern struct FontRequester *FontReq;
  6. extern struct ScreenModeRequester *ScrReq;
  7. extern struct TextAttr *TAttr;
  8.  
  9. //void CreateDefaultModeList(struct List *List);
  10. //void FreeDefaultModeList(struct List *List);
  11.  
  12.  
  13. BYTE ModeSelectDoDims[]={0,0,1,1,0};
  14.  
  15. BOOL PickFont(struct Window *Win, struct TTextAttr *TA)
  16. {
  17.   ULONG skip=0;
  18.   WORD width;
  19.  
  20.   if(TA)
  21.   {
  22.     if(!FontReq)
  23.     {
  24.       width=Win->Width/2;
  25.       FontReq=(struct FontRequester *)AllocAslRequestTags(ASL_FontRequest, 
  26.                       ASLFO_TextAttr,        TAttr,
  27.                       ASLFO_InitialTopEdge,  Win->TopEdge+8,
  28.                       ASLFO_InitialLeftEdge, Win->LeftEdge+width/2,
  29.                       ASLFO_InitialWidth,    width,
  30.                       ASLFO_InitialHeight,   Win->Height-16,
  31.                       ASLFO_TitleText,       MiscText[SELECT_SCREEN_FONT],
  32.                       ASLFO_DoStyle,         TRUE,
  33.                       ASLFO_MinHeight,       1,
  34.                       ASLFO_MaxHeight,       65535,
  35.                       ASLFO_PrivateIDCMP,    TRUE,
  36.                       TAG_DONE);
  37.     }
  38.     if(FontReq)
  39.     {
  40.       if(!TA->tta_Name)
  41.         skip=4;
  42.       if(AslRequestTags(FontReq, 
  43.                       ASLFO_Window,          Win,
  44.                       ASLFO_SleepWindow,     TRUE,
  45.                       TAG_SKIP,              skip,
  46.                       ASLFO_InitialName,     TA->tta_Name,
  47.                       ASLFO_InitialSize,     TA->tta_YSize,
  48.                       ASLFO_InitialStyle,    TA->tta_Style,
  49.                       ASLFO_InitialFlags,    TA->tta_Flags,
  50.                       TAG_DONE))
  51.       {
  52.         ObtainSemaphore(&MPSem->NodeSem);
  53.         FreeVec(TA->tta_Name);
  54.         if(TA->tta_Name=AllocVec(strlen(FontReq->fo_TAttr.tta_Name)+1,MEMF_PUBLIC|MEMF_CLEAR))
  55.           strcpy(TA->tta_Name,FontReq->fo_TAttr.tta_Name);
  56.         TA->tta_YSize = FontReq->fo_TAttr.tta_YSize;
  57.         TA->tta_Style = FontReq->fo_TAttr.tta_Style & (~FSF_TAGGED);
  58.         TA->tta_Flags = FontReq->fo_TAttr.tta_Flags;
  59.         ReleaseSemaphore(&MPSem->NodeSem);
  60.         return(TRUE);
  61.       }   
  62.     }
  63.   }
  64.   return(FALSE);
  65. }
  66.  
  67.  
  68. ULONG SelectScreenMode(struct Window *Win, struct DefaultNode *n, BOOL DoOrig)
  69. {
  70.   UBYTE dodims;
  71.   UBYTE title[100]={0};
  72.   WORD width;
  73.   ULONG retval=0;
  74.   struct List defmodelist;
  75.   
  76.   STRPTR selectstring="%s";
  77.   
  78.   NewList(&defmodelist);
  79.   
  80.   if(!DoOrig)
  81.   {
  82.     switch(n->ModeSelect)
  83.     {
  84.       case MS_PROMOTE_MONITOR:
  85.         selectstring=GetString(MSG_REQ_SELECT_MONITOR_FOR);
  86.         break;
  87.       case MS_PROMOTE_SCREENMODE:
  88.       case MS_PROMOTE_REQUESTER:
  89.         selectstring=GetString(MSG_REQ_SELECT_SCREENMODE_FOR);
  90.         break;
  91.     }      
  92.     sprintf(title,selectstring,n->Def_Node.ln_Name);
  93.   }
  94.   else
  95.   {
  96.     strcpy(title,GetString(MSG_SELWIN_SCRMODES));
  97.     //CreateDefaultModeList(&defmodelist);
  98.   }
  99.    
  100.   if(!ScrReq)
  101.   {
  102.     width=Win->Width/2;
  103.     ScrReq=(struct ScreenModeRequester *)AllocAslRequestTags(ASL_ScreenModeRequest, 
  104.                     ASLSM_TextAttr,              TAttr,
  105.                     ASLSM_InitialTopEdge        ,Win->TopEdge+8,
  106.                     ASLSM_InitialLeftEdge       ,Win->LeftEdge+width/2,
  107.                     ASLSM_InitialWidth          ,width,
  108.                     ASLSM_InitialHeight         ,Win->Height-16,
  109.                     ASLSM_PropertyFlags         ,0,
  110.                     ASLSM_PropertyMask          ,DIPF_IS_PF2PRI,//BADMODES,
  111.                     ASLSM_PrivateIDCMP,          TRUE,
  112.                     TAG_END);
  113.   }
  114.   if(ScrReq)
  115.   {
  116.     dodims=ModeSelectDoDims[n->ModeSelect] && (!DoOrig);
  117.     if(AslRequestTags(ScrReq,
  118.                     ASLSM_Window                ,Win,
  119.                     ASLSM_TitleText             ,title,
  120.                     ASLSM_SleepWindow           ,TRUE,
  121.                     ASLSM_DoWidth               ,dodims ,
  122.                     ASLSM_DoHeight              ,dodims ,
  123.                     ASLSM_DoOverscanType        ,dodims ,
  124.                     ASLSM_DoAutoScroll          ,dodims ,
  125.                     TAG_SKIP                    ,(DoOrig ? 0:2),
  126.                     ASLSM_DoDepth               ,FALSE,
  127.                     ASLSM_InitialDisplayID      ,n->OrigDisplayID,
  128.                     TAG_SKIP                    ,(DoOrig ? 7:0),   
  129.                     ASLSM_DoDepth               ,(n->Flags & DEPTH) && dodims,
  130.                     ASLSM_InitialAutoScroll     ,n->AutoScroll,
  131.                     ASLSM_InitialDisplayWidth   ,n->Width,
  132.                     ASLSM_InitialDisplayHeight  ,n->Height,
  133.                     ASLSM_InitialDisplayID      ,n->ModeID, 
  134.                     ASLSM_InitialDisplayDepth   ,n->Depth,
  135.                     ASLSM_InitialOverscanType   ,n->OverscanType,
  136. //                    ASLSM_CustomSMList          ,defmodelist,          
  137.                     TAG_DONE))
  138.     {
  139.       ObtainSemaphore(&MPSem->NodeSem);
  140.  
  141.       if(DoOrig)
  142.         n->OrigDisplayID=ScrReq->sm_DisplayID;
  143.       else
  144.       {
  145.         n->ModeID       =ScrReq->sm_DisplayID;
  146.         if(dodims)
  147.         {  
  148.           n->Width        =ScrReq->sm_DisplayWidth;
  149.           n->Height       =ScrReq->sm_DisplayHeight;
  150.           n->OverscanType =ScrReq->sm_OverscanType;
  151.           n->Depth        =ScrReq->sm_DisplayDepth;
  152.         }
  153.         n->AutoScroll   =ScrReq->sm_AutoScroll;   
  154.       }
  155.       retval=TRUE;
  156.       ReleaseSemaphore(&MPSem->NodeSem);
  157.     }
  158.   }
  159.   //FreeDefaultModeList(&defmodelist);
  160.   return(retval);
  161. }
  162. /*
  163. void CreateDefaultModeList(struct List *List)
  164. {
  165.   struct DisplayInfo  dinfo;
  166.   struct DisplayMode *dmode;  
  167.   ULONG id,ok;
  168.   
  169.   id=NextDisplayInfo(INVALID_ID);
  170.   while(id!=INVALID_ID && !(id&MONITOR_ID_MASK))
  171.   {
  172.     if(GetDisplayInfoData(0,(UBYTE *)&dinfo,sizeof(dinfo),DTAG_DISP,id))
  173.     {
  174.       if(!(dinfo.PropertyFlags & SPECIAL_FLAGS))
  175.       {
  176.         ok=FALSE;
  177.         if(dmode=AllocVec(sizeof(struct DisplayMode),MEMF_PUBLIC|MEMF_CLEAR))
  178.         {
  179.           if(dmode->dm_Node.ln_Name=GetModeName(id))
  180.           {
  181.             if(GetDisplayInfoData(0,(UBYTE *)&dmode->dm_DimensionInfo,sizeof(dmode->dm_DimensionInfo),DTAG_DIMS,id))
  182.             { 
  183.               dmode->dm_PropertyFlags=dinfo.PropertyFlags;
  184.               AddTail(List,(struct Node *)dmode);
  185.               ok=TRUE;
  186.             }
  187.           }
  188.           if(!ok)
  189.           {
  190.             FreeVec(dmode->dm_Node.ln_Name);
  191.             FreeVec(dmode);
  192.           }
  193.         }
  194.       }
  195.     }
  196.     id=NextDisplayInfo(id);
  197.   }
  198. }
  199.   
  200. void FreeDefaultModeList(struct List *List)
  201. {
  202.   struct DisplayMode *dmode;  
  203.   
  204.   while(dmode=(struct DisplayMode *)RemHead(List))
  205.   {
  206.     FreeVec(dmode->dm_Node.ln_Name);
  207.     FreeVec(dmode);
  208.   }
  209. }      
  210. */